﻿Imports dllEntidades

Partial Class Pagina_MPSantander
    Inherits System.Web.UI.MasterPage

#Region "PROCEDIMIENTOS Y FUNCIONES"
    Function ValidarSession() As Boolean
        Dim bolResul As Boolean = False
        Try
            If Session("LogueadoSPEC") = "SI" Then
                bolResul = True
            End If
        Catch ex As Exception
        End Try
        Return bolResul
    End Function

    Private Sub GenerarMenu()
        Me.tdConvenios.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper = "SI", True, False)
        Me.tdEventos.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper = "SI", True, False)
        Me.tdNoticias.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper = "SI", True, False)
        Me.tdUsuarios.Visible = False 'IIf(Session("EsADM").ToString.Trim.ToUpper = "SI", True, False)
        Me.tdInscribirConvenios.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper <> "SI", True, False)
        Me.tdInscribirEventos.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper <> "SI", True, False)
        Me.tdInformeConvenio.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper = "SI", True, False)
        Me.tdInformeEvento.Visible = IIf(Session("EsADM").ToString.Trim.ToUpper = "SI", True, False)
    End Sub
#End Region

#Region "EVENTOS DE PAGINA"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If ValidarSession() = True Then
                Dim NegocioP As New dllNegocio.NegPersonas(System.Configuration.ConfigurationManager.AppSettings.Get("SPECBDD").ToString.Trim)
                Dim objUsr As New dllEntidades.clsFuncionario
                Try
                    objUsr = NegocioP.BuscaPersona(Session("RutUsuario"))
                    Me.lblUsuario.Text = objUsr.Nombre & " " & objUsr.ApellidoPaterno & " " & objUsr.ApellidoMaterno & " - " & objUsr.Sucursal
                    Call GenerarMenu()
                Catch ex As Exception
                    UtilidadesPagina.mensaje(ex.Message.ToString, Me.Page)
                Finally
                    NegocioP.Dispose()
                    NegocioP = Nothing
                    objUsr.Dispose()
                    objUsr = Nothing
                End Try
            Else
                Response.Redirect("ErrorAcceso.aspx")
                Response.End()
            End If
        End If
    End Sub

    Protected Sub imgCerrarSession_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgCerrarSession.Click
        Session("RutUsuario") = Nothing
        Session("EsADM") = Nothing
        Session("LogueadoSPEC") = Nothing
        Response.Redirect("../Default.aspx")
        Response.End()
    End Sub

#End Region
End Class

